import { ConfigEnum, MicroServiceEnum } from '@/common/enums/httpEnum'

const Url = {
  getQuestionList: `/api/survey-questionnaire/user-list-data`,
  getQuestionDetail: `/api/survey-questionnaire/detail`,
  submitQuestion: `/api/survey-questionnaire/submit`,
  ifPopup: `/api/survey-questionnaire/popup`,
  checkQuestionAuth: '/api/survey-questionnaire/check-user-auth',
  getFormScene: '/api/survey-questionnaire/get-survey-questionnaire',
}

//获取问卷列表
export const getQuestionList = (params) =>
  uni.$uv.http.get(Url.getQuestionList, { params, header: { [ConfigEnum.MICRO_SERVICE_PLATFORM]: MicroServiceEnum.GATEWAY, authorization: 'szct' }, custom: { showLoading: true } })
//移动端获取用户问卷详情
export const getQuestionDetail = (params) =>
  uni.$uv.http.get(Url.getQuestionDetail, {
    params,
    header: { [ConfigEnum.MICRO_SERVICE_PLATFORM]: MicroServiceEnum.GATEWAY, authorization: 'szct' },
    custom: { showLoading: true },
  })
//用户提交问卷答案
export const submitQuestion = (data) =>
  uni.$uv.http.post(Url.submitQuestion, data, {
    header: { [ConfigEnum.MICRO_SERVICE_PLATFORM]: MicroServiceEnum.GATEWAY, authorization: 'szct', 'Content-Type': 'application/json' },
    custom: { showLoading: true },
  })
//是否弹出问卷
export const ifPopup = (params) =>
  uni.$uv.http.get(Url.ifPopup, { params, header: { [ConfigEnum.MICRO_SERVICE_PLATFORM]: MicroServiceEnum.GATEWAY, authorization: 'szct' }, custom: { showLoading: true } })

//获取用户是否有权限答卷
export const checkQuestionAuth = (params) =>
  uni.$uv.http.get(Url.checkQuestionAuth, {
    params,
    header: { [ConfigEnum.MICRO_SERVICE_PLATFORM]: MicroServiceEnum.GATEWAY, authorization: 'szct' },
    custom: { showLoading: true },
  })

//通过scene获取题目id
export const getFormScene = (params) =>
  uni.$uv.http.get(Url.getFormScene, { params, header: { [ConfigEnum.MICRO_SERVICE_PLATFORM]: MicroServiceEnum.GATEWAY, authorization: 'szct' } })
